const timer = () => {
  return new Promise((resolve) => {
    setTimeout(() => {
      //   reject("报错了");
      resolve(2);
      // console.log(2);
      //   return 2;
    }, 1500);
  });
};
// let arr = []
// timer().then(res => {
//     arr.push(res)
//     timer().then((res1) => {
//       arr.push(res1);
//       timer().then(res2 =>{
//         arr.push(res2)
//         console.log(arr)
//       })
//     });
// })
// log()
async function handleAjax() {
  try {
    const res = await timer();
    const res1 = await timer();
    const res2 = await timer();
    const res3 = await timer();
    const res4 = await timer();
    const res5 = await timer();
    return [res, res1, res2, res3, res4, res5];
  } catch (error) {
    // console.log(error);
    // Promise.reject(error);
    throw new Error(error);
  }
}
// handleAjax()

// (() => {
// (async () => {
try {
  const res = await handleAjax();
  console.log(res, "******");
} catch (error) {
  console.log(error);
}
// })();
// })();
// handleAjax().then((res) => {
//   console.log(res);
// });
